<?php
header('Content-type: text/html; charset=UTF-8');
$type = $_GET["type"];
//浏览器
$enday = date('Ymd',strtotime('-1 day'));  
if($type == 2){ //update
	$enday = $_GET["enday"];
	$enday = date("Ymd",strtotime($enday));
}

$uploaddir = getcwd();
$app_name_crash = $uploaddir.'/../../crashemail/topcrash/'.'7.9.0.55_'.$enday.'_topcrash.txt';
$app_name_native = $uploaddir.'/../../crashemail/topcrash/'.'7.9.0.55_'.$enday.'_topnativecrash.txt';
$crash_data_fp = fopen($app_name_crash,'r');
$native_data_fp = fopen($app_name_native,'r');
$crash_link = 'http://10.212.183.60/crash_log/7.9.0.55_'.$enday.'_zeus_bugs.zip';
$native_link = 'http://10.212.183.60/crash_log/7.9.0.55_'.$enday.'_system_bugs.zip';
//手百
$box_name_crash = $uploaddir.'/../../crashemail/topcrash/'.'7.6.2.39_'.$enday.'_topcrash.txt';
$box_name_native = $uploaddir.'/../../crashemail/topcrash/'.'7.6.2.39_'.$enday.'_topnativecrash.txt';
$crash_box_data_fp = fopen($box_name_crash,'r');
$native_box_data_fp = fopen($box_name_native,'r');
$crash_box_link = 'http://10.212.183.60/crash_log/7.6.2.39_'.$enday.'_zeus_bugs.zip';
$native_box_link = 'http://10.212.183.60/crash_log/7.6.2.39_'.$enday.'_system_bugs.zip';

$result_str = '<div class="mala-row">
                <div class="mala-col-md-6">
				<h3 class="mala-panel-title">Browser T7 TOP30崩溃：(详细日志见：<a href="'.$crash_link.'">TOP30崩溃日志</a>)</h3>' ;

$str = '<table class="gridtable"><tr><th style="width:8%;">序号</th><th style="width:12%;">崩溃次数</th><th>崩溃位置</th></tr>';  
$num = 0;
while (!feof($crash_data_fp)){
	$line = fgets($crash_data_fp);
	$num = $num + 1;
	if($num <= 30){
		$str = $str.'<tr>';
		$values = explode('	', $line);
		$str = $str."<td>$num</td>";
		foreach($values as $value){
			$str = $str."<td>$value</td>";
		}
		$str = $str.'</tr>';
	}else{
		break;
	}
}
fclose($crash_data_fp);
$str = $str.'</table>';
$result_str = $result_str.$str;

$result_str = $result_str.'</div>
                <div class="mala-col-md-6">
				<h3 class="mala-panel-title">Box T7 TOP30崩溃：(详细日志见：<a href="'.$crash_box_link.'">TOP30崩溃日志</a>)</h3>';

$str = '<table class="gridtable"><tr><th style="width:8%;">序号</th><th style="width:12%;">崩溃次数</th><th>崩溃位置</th></tr>';  
$num = 0;
while (!feof($crash_box_data_fp)){
	$line = fgets($crash_box_data_fp);
	$num = $num + 1;
	if($num <= 30){
		$str = $str.'<tr>';
		$values = explode('	', $line);
		$str = $str."<td>$num</td>";
		foreach($values as $value){
			$str = $str."<td>$value</td>";
		}
		$str = $str.'</tr>';
	}else{
		break;
	}
}
fclose($crash_box_data_fp);
$str = $str.'</table>';
$result_str = $result_str.$str;

$result_str =$result_str.'</div>
            </div>
			
			<div class="mala-row">
                <div class="mala-col-md-6">
				<h3 class="mala-panel-title">Browser Native TOP30崩溃：(详细日志见：<a href="'. $native_link.'">TOP30崩溃日志</a>)</h3>';

$str = '<table class="gridtable"><tr><th style="width:8%;">序号</th><th style="width:12%;">崩溃次数</th><th>崩溃位置</th></tr>';  
$num = 0;
while (!feof($native_data_fp)){
	$line = fgets($native_data_fp);
	$num = $num + 1;
	if($num <= 30){
		$str = $str.'<tr>';
		$values = explode('	', $line);
		$str = $str."<td>$num</td>";
		foreach($values as $value){
			$str = $str."<td>$value</td>";
		}
		$str = $str.'</tr>';
	}else{
		break;
	}
}
fclose($native_data_fp);
$str = $str.'</table>';
$result_str = $result_str.$str;

$result_str =$result_str.'</div>
                <div class="mala-col-md-6">
				<h3 class="mala-panel-title">Box Native TOP30崩溃：(详细日志见：<a href="'. $native_box_link.'">TOP30崩溃日志</a>)</h3>';

$str = '<table class="gridtable"><tr><th style="width:8%;">序号</th><th style="width:12%;">崩溃次数</th><th>崩溃位置</th></tr>';  
$num = 0;
while (!feof($native_box_data_fp)){
	$line = fgets($native_box_data_fp);
	$num = $num + 1;
	if($num <= 30){
		$str = $str.'<tr>';
		$values = explode('	', $line);
		$str = $str."<td>$num</td>";
		foreach($values as $value){
			$str = $str."<td>$value</td>";
		}
		$str = $str.'</tr>';
	}else{
		break;
	}
}
fclose($native_box_data_fp);
$str = $str.'</table>';
$result_str = $result_str.$str;
$result_str = $result_str.'</div>
            </div>';
echo $result_str;
?>